﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace peonwar
{
    class ResearchFour : Research
    {
        Timer countDown;
        int rest;
        public ResearchFour(Vector2 _position, Texture2D _texture, User au)
            : base(_position, _texture, au)
        {

            rest = 0;

            name = GameData.GameString[177];
            description = GameData.GameString[178];

            countDown = new Timer(90);

            time = 125;
            timer = new Timer(time);
            SonLeft = new ResearchEigth(new Vector2(_position.X - 42, _position.Y + 110), GameTexture.Researchs[7], au);
            SonRight = new ResearchNine(new Vector2(_position.X + 42, _position.Y + 110), GameTexture.Researchs[8], au);
        }

        public override void competance()
        {
            if (countDown.UpdateTimer())
            {
                countDown.RestartTimer();
                rest = 3;
            }
            if (rest > 0)
            {
                rest--;
                Unit renfort = new UnitLight3(associatedUser);
                renfort.Cost = 0;
                renfort.drawingColor = Color.Aquamarine;
                if(associatedUser.isIA)
                    associatedUser.addPeonToBuffer(renfort);
                else
                    associatedUser.SpawnUnit(renfort);
            }
        }
    }
}
